/*
=======================================================================

  BOTS Berzerker Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_BERZERKER_RAGE			140
#define BOTS_BERZERKER_CHARGE		141

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	rage;
  menutext_s	charge;
  menutext_s	cancel;
} berzerkerCommands_t;

static berzerkerCommands_t		s_berzerker;

/*
=================
BOTS_BerzerkerCommandsMenu_Event
callback routine
=================
*/
void BOTS_BerzerkerCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_BERZERKER_RAGE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "rage\n" );
		break;
	case BOTS_BERZERKER_CHARGE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "charge\n" );
		break;
		
	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_BerzerkerCommandsMenu_Init
=================
*/
void BOTS_BerzerkerCommandsMenu_Init() 
{
	int y;

	memset( &s_berzerker, 0 ,sizeof(berzerkerCommands_t) );
	s_berzerker.menu.wrapAround = qtrue;
	s_berzerker.menu.fullscreen = qfalse;

	y = 96;
	s_berzerker.title.generic.type	= MTYPE_PTEXT;
	s_berzerker.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_berzerker.title.generic.x		= 320;
	s_berzerker.title.generic.y		= y;
	s_berzerker.title.string		= "BERZERKER COMMANDS MENU";
	s_berzerker.title.color			= color_bots_menu;
	s_berzerker.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_berzerker.rage.generic.type		= MTYPE_PTEXT;
	s_berzerker.rage.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_berzerker.rage.generic.x			= 320;
	s_berzerker.rage.generic.y			= y;
	s_berzerker.rage.generic.id			= BOTS_BERZERKER_RAGE;
	s_berzerker.rage.generic.callback	= BOTS_BerzerkerCommandsMenu_Event; 
	s_berzerker.rage.string				= "INVINCIBLE RAGE - rage";
	s_berzerker.rage.color				= color_bots_menu;
	s_berzerker.rage.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_berzerker.charge.generic.type		= MTYPE_PTEXT;
	s_berzerker.charge.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_berzerker.charge.generic.x		= 320;
	s_berzerker.charge.generic.y		= y;
	s_berzerker.charge.generic.id		= BOTS_BERZERKER_CHARGE;
	s_berzerker.charge.generic.callback	= BOTS_BerzerkerCommandsMenu_Event; 
	s_berzerker.charge.string			= "CHARGE - charge";
	s_berzerker.charge.color			= color_bots_menu;
	s_berzerker.charge.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_berzerker.cancel.generic.type		= MTYPE_PTEXT;
	s_berzerker.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_berzerker.cancel.generic.x		= 320;
	s_berzerker.cancel.generic.y		= y;
	s_berzerker.cancel.generic.id		= BOTS_CANCEL;
	s_berzerker.cancel.generic.callback	= BOTS_BerzerkerCommandsMenu_Event; 
	s_berzerker.cancel.string			= "CANCEL";
	s_berzerker.cancel.color			= color_bots_menu;
	s_berzerker.cancel.style			= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_berzerker.menu, &s_berzerker.title );
	Menu_AddItem( &s_berzerker.menu, &s_berzerker.rage );
	Menu_AddItem( &s_berzerker.menu, &s_berzerker.charge );
	Menu_AddItem( &s_berzerker.menu, &s_berzerker.cancel );
}

void BOTS_BerzerkerCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_BerzerkerCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_berzerker.menu );
}
